package com.example.xd.sdk_test;

import android.util.Log;

import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 * map双列集合（HashMap treeMap）
 * collection 单例集合（list(arraylist linkedList) set(hashSet treeSet)）
 *
 * @auther XuDan on 2019/4/16.
 */
public class HashTest {
    HashMap<Integer, String> hm = new HashMap();
    HashSet hs = new HashSet();
    TreeMap tm = new TreeMap();
    TreeSet ts = new TreeSet();

    public void init() {
        hs.add("sss");
        ts.add("sss");
//        Collections

    }

    public static void hmTest() {
        HashMap<Integer, String> hm = new HashMap();
        hm.put(1, "第一");
        hm.put(2, "第二");
        hm.put(3, "第三");
        hm.put(4, "第四");
        hm.put(5, "第五");
        hm.put(6, "第六");

        Set<Integer> integers = hm.keySet();
        for (Integer i : integers) {
            String s = hm.get(i);
            System.out.println("xd----key==" + i + "---value==" + s);
        }
        System.out.println("----------------------------------------------");
        Set<Map.Entry<Integer, String>> entries = hm.entrySet();
        for (Map.Entry<Integer, String> map : entries) {
            System.out.println("map------" + map.toString() + "---");
            String value = map.getValue();
            Integer key = map.getKey();
            System.out.println("xd----key==" + key + "---value==" + value);

        }
    }
}
